/*
 * Copyright (c) 2021 Futurewei Technologies, Inc.
 *
 * clang2mpl is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PSL v2. You may obtain a copy of Mulan PSL v2 at:
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
 * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the
 * Mulan PSL v2 for more details.
 */
// RUN: %clang2mpl --ascii --verify %s -- --target=aarch64-linux-elf
// RUN: cat %m | %FileCheck %s

// CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
// CHECK-NEXT: var $c u8 = 97
char c = 'a';
// CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
// CHECK-NEXT: var $uc u8 = 98
unsigned char uc = 'b';
// CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
// CHECK-NEXT: var $s i16 = 1
short s = 1;
// CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
// CHECK-NEXT: var $us u16 = 2
unsigned short us = 2;
// CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
// CHECK-NEXT: var $i i32 = -3
int i = -3;
// CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
// CHECK-NEXT: var $ui u32 = 4
unsigned int ui = 4;
// CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
// CHECK-NEXT: var $l i64 = 5
long l = 5L;
// CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
// CHECK-NEXT: var $ul u64 = 0x8ae
unsigned long ul = 2222UL;
// CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
// CHECK-NEXT: var $ll i64 = -1234567
long long ll = -1234567LL;
// CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
// CHECK-NEXT: var $ull u64 = 0x3ade68b1
unsigned long long ull = 987654321ULL;
// CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
// CHECK-NEXT: var $str <* u8> = conststr a64 "hello"
char *str = "hello";

void foo(void) {
  // CHECK: LOC 2 [[#LC_LINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: var %lc u8
  char lc = 'a';
  // CHECK: LOC 2 [[#LUC_LINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: var %luc u8
  unsigned char luc = 'b';
  // CHECK: LOC 2 [[#LS_LINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: var %ls i16
  short ls = 1;
  // CHECK: LOC 2 [[#LUS_LINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: var %lus u16
  unsigned short lus = 2;
  // CHECK: LOC 2 [[#LI_LINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: var %li i32
  int li = -3;
  // CHECK: LOC 2 [[#LUI_LINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: var %lui u32
  unsigned int lui = 4;
  // CHECK: LOC 2 [[#LL_LINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: var %ll i64
  long ll = 5L;
  // CHECK: LOC 2 [[#LUL_LINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: var %lul u64
  unsigned long lul = 2222UL;
  // CHECK: LOC 2 [[#LLL_LINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: var %lll i64
  long long lll = -1234567LL;
  // CHECK: LOC 2 [[#LULL_LINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: var %lull u64
  unsigned long long lull = 987654321ULL;
  // CHECK: LOC 2 [[#LSTR_LINE: @LINE + 2 ]]{{$}}
  // CHECK-NEXT: var %lstr <* u8>
  char *lstr = "hello";

  // CHECK: LOC 2 [[#LC_LINE]]{{$}}
  // CHECK: dassign %lc 0 (constval u32 97)
  // CHECK: LOC 2 [[#LUC_LINE]]{{$}}
  // CHECK: dassign %luc 0 (constval u32 98)
  // CHECK: LOC 2 [[#LS_LINE]]{{$}}
  // CHECK: dassign %ls 0 (constval i32 1)
  // CHECK: LOC 2 [[#LUS_LINE]]{{$}}
  // CHECK: dassign %lus 0 (constval u32 2)
  // CHECK: LOC 2 [[#LI_LINE]]{{$}}
  // CHECK: dassign %li 0 (constval i32 -3)
  // CHECK: LOC 2 [[#LUI_LINE]]{{$}}
  // CHECK: dassign %lui 0 (constval u32 4)
  // CHECK: LOC 2 [[#LL_LINE]]{{$}}
  // CHECK: dassign %ll 0 (constval i64 5)
  // CHECK: LOC 2 [[#LUL_LINE]]{{$}}
  // CHECK: dassign %lul 0 (constval u64 0x8ae)
  // CHECK: LOC 2 [[#LLL_LINE]]{{$}}
  // CHECK: dassign %lll 0 (constval i64 -1234567)
  // CHECK: LOC 2 [[#LULL_LINE]]{{$}}
  // CHECK: dassign %lull 0 (constval u64 0x3ade68b1)
  // CHECK: LOC 2 [[#LSTR_LINE]]{{$}}
  // CHECK: dassign %lstr 0 (conststr a64 "hello")
}
